<template>
  <section>
    <div class="model myfile">
      <img :src="IMGBASE64.WODEWENJIAN2X" class="pink">
      <span class="title">部门管理</span>
      <div class="kong"></div>
      <div class="t_title">
        <img>
        <span class="f-blue">学校组织架构</span>
      </div>
      <div class="tree">
          <el-tree
          ref="tree"
          :data="data"
          :props="defaultProps"
          accordion
          node-key="code"
          :default-expanded-keys="[100]">
        </el-tree>
      </div>
    </div>
    


    <div class="dright">
      <span class="dspan">学校选择:</span>
      <select class="select" v-model="subjectSelect">
        <option v-for="(item, key) in subjectOption" :label="item" :value="key"></option>
      </select>

      <div class="t_title">
        <img>
        <span class="f-blue">学校组织架构</span>
      </div>

      <div class="tree">
        <el-tree
        show-checkbox
        ref="tree"
        :data="data2"
        :props="defaultProps"
        accordion
        node-key="code"
        :default-expanded-keys="[100]">
      </el-tree>
      <el-button class="t-btn" type="danger">确认提交</el-button>
      <!-- <button class="btn btn-danger">确认提交</button> -->
    </div>
    </div>

    <div class="up" v-show="upShow">
      <img :src="IMGBASE64.GREENXINZENG2X" class="green">
      <span class="title">新建</span>
      <el-button icon="close" class="close" @click="upshow()"></el-button>
      <header>
        <span class="header-title">基本信息</span>
      </header>
      <div class="form">
        <div class="firstLine">
          <span>部门名称:</span>
          <input type="text" class="form-longText">
        </div>
        <div class="secondLine">
          <span>创建角色:</span>
          <ul>
            <li><span>角色1</span><input type="text" class="form-text"></li>
            <li><span>角色2</span><input type="text" class="form-text"></li>
            <li><span>角色3</span><input type="text" class="form-text"></li>
          </ul>
        </div>
      </div>
      <div class="bottom">
        <div class="right">
          <el-button type="success">确定</el-button>
        </div>
      </div>
    </div>

    <transition name="modal-shadow">
      <div class="modal-backdrop" v-show="upShow"></div>
    </transition>
  </section>
</template>

<script>
// let code = 1000
export default {
  data () {
    return {
      expand: [100],
      subjectSelect: '',
      subjectOption: ['天神小学', '天神小学', '天神小学'],
      upShow: false,
      data: [{
        code: '110',
        label: '校长室',
        children: [{
          code: '111',
          label: '校长'
        }, {
          code: '112',
          label: '副校长'
        }]
      }, {
        code: '120',
        label: '招生办',
        children: [{
          code: '121',
          label: '路人已'
        }]
      }, {
        code: '120',
        label: '招生办',
        children: [{
          code: '121',
          label: '路人已'
        }]
      }, {
        code: '120',
        label: '招生办',
        children: [{
          code: '121',
          label: '路人已'
        }]
      }],
      data2: [{
        code: '110',
        label: '校长室',
        children: [{
          code: '111',
          label: '校长'
        }, {
          code: '112',
          label: '副校长'
        }]
      }, {
        code: '120',
        label: '招生办',
        children: [{
          code: '121',
          label: '路人已'
        }]
      }, {
        code: '120',
        label: '招生办',
        children: [{
          code: '121',
          label: '路人已'
        }]
      }, {
        code: '120',
        label: '招生办',
        children: [{
          code: '121',
          label: '路人已'
        }]
      }],
      defaultProps: {
        children: 'children',
        label: 'label'
      }
    }
  },
  // mounted () {
  //   this.$refs.tree.$el.firstElementChild.firstElementChild.lastElementChild.lastElementChild.childNodes[1].style.display = 'none'
  //   this.$refs.tree.$el.firstElementChild.firstElementChild.lastElementChild.lastElementChild.childNodes[2].style.display = 'none'
  // },
  methods: {
    mover (ev) {
      ev.path[2].lastElementChild.style.opacity = 0
    },
    mout (ev) {
      ev.path[2].lastElementChild.style.opacity = 1
      // console.log(ev)
    },
    // nodeClick () {
    //   for (var i = 0; i < this.$refs.tree.$el.lastElementChild.lastElementChild.childNodes.length; i++) {
    //     for (var a = 0; a < this.$refs.tree.$el.lastElementChild.lastElementChild.childNodes[i].lastElementChild.childNodes.length; a++) {
    //       this.$refs.tree.$el.lastElementChild.lastElementChild.childNodes[i].lastElementChild.childNodes[a].firstElementChild.lastElementChild.lastElementChild.firstElementChild.style.display = 'none'
    //     }
    //   }
    //   // console.log(this.$refs.tree)
    // },
    append (store, data) {
      // store.append({ code: code++, label: 'testtest', children: [] }, data)
      this.upShow = true
    },
    change (store, data) {
      // store.append({ code: code++, label: 'testtest', children: [] }, data)
      this.upShow = true
    },
    remove (store, data) {
      store.remove(data)
    },
    // renderContent (h, { node, data, store }) {
    //   return (
    //     <span>
    //       <span>
    //         <span on-click={ ($event) => this.mout($event) } on-dblclick={ ($event) => this.mover($event) }>{node.label}</span>
    //       </span>
    //       <span class="span" style="float: right; margin-right: 20px">
    //         <el-button size="mini" on-click={ () => this.append(store, data) }>新建子集</el-button>
    //         <el-button type="warning" size="mini" on-click={ () => this.change(store, data) }>修改</el-button>
    //         <el-button type="danger" size="mini" on-click={ () => this.remove(store, data) }>删除</el-button>
    //       </span>
    //     </span>
    //   )
    // },
    upshow () {
      this.upShow = !this.upShow
    }
  }
}
</script>

<style>
  @import '/static/css/demo-documentation.css';
  .myfile{
    width:54%;
    min-width: 595.67px;
    height: 440px;
  }
  .myfile .el-tree{
    position: relative; left: 42%;
    width: 210.1%;
    border: none;
  }
  .myfile .t_title{
    position: relative; left: 18%;
  }
  .myfile .t_title img{
    float: left;
    width: 20px; height: 20px;
    background: #ccc;
    margin-right: 1%;
  }
  section .line{
    position: absolute; left: 55%; top: 60px;
    width: 1px; height: 56%;
    border-left: 1px dashed #666;
  }
  section .dright{
    position: absolute; right: 2%; top: 51px;
    width: 40%; height: 460px;
    background: #fff;
    border-radius: 4px;
  }
  section .dright .t_title{
    margin-top: 20px;
    margin-left: 6%;
  }
  section .dright .t_title img{
    float: left;
    width: 20px; height: 20px;
    background: #ccc;
    margin-right: 1%;
  }
  section .dright .dspan{
    position: relative; top: 12px;
    margin-left: 6%;
  }
  section .dright select{
    position: relative; top: 12px;
    width: 54%;
    border: none;
    border-bottom: 1px solid #ccc;
  }
  section .dright .t-btn{
    position: relative; left: 34%; top: 14px;
  }
  section .dright .tree{
    position: relative; left: 6%; top: 10px;
    width: 90%;
  }
  section .tree{
    position: relative; left: 2%; top: 14px;
  }
  div[data-v-22bf8d34] ul
  {
    position: relative;
    left: 12%;
  }
  div[data-v-22bf8d34]
  {
    padding-bottom: 10px;
  }
  .el-upload--picture-card
  {
    margin-left: 9%; 
    margin-top: 40px;
    width: 80px; height: 80px;
  }
  .el-upload--picture-card i
  {
    position: relative; top: -28px;
  }
  .tree{
    position: relative; left: 60%;
    width: 40%;
  }
  .span{
    opacity: 0;
  }

  .up{
    width: 60%;
    position: absolute;
    top: 10%;
    left: 25%;
    background: #FFF;
    padding: 20px 20px 0 20px;
    border-radius: 5px;
    z-index: 99999;
  }
  .up .img{
    position: absolute;
    left: 24px;
    top: -20px;
  }
  .up .title{
    margin-left: 90px;
  }
  .up header{
    border-bottom: 2px solid #D7D7D7;
    padding: 30px 0 10px 0;
    margin-left: 1%;
    margin-right: 10px;
    margin-bottom: 10px;
  }
  .up .header-title{
    color: #FB7862;
    border-bottom: 2px solid #FB7862;
    padding: 0 10px 10px 10px;
    margin-left: 0;
  }
  .up .form{
    margin-left: 10%;
    margin-right: 10px;
  }
  .up .form .firstLine{
    padding: 30px 0 10px 0;
  }
  .up .form .secondLine{
    padding: 30px 0 50px 0;
  }
  .up .form .form-longText{
    width: 50%;
    border: 0;
    border-bottom: 1px solid #D7D7D7;
  }
  .up .form .form-text{
    width: 70%;
    border: 0;
    border-bottom: 1px solid #D7D7D7;
  }
  .up ul{
    margin-top: 30px;
    margin-left: 75px;
  }
  .up ul li{
    float: left;
  }
  .up .bottom{
    border-top: 1px solid #D7D7D7;
    margin-top: 20px;
    background: #F8F8F8;
    padding: 8px 0;
    margin-left: -20px;
    margin-right: -20px;
    border-radius: 0 0 5px 5px;
  }
  .up .bottom .right{
    text-align: right;
    padding: 0 10px 0 0;
  }
</style>
